package com.example.demo_job.mapper;


import com.example.demo_job.entity.*;
import com.example.demo_job.utils.R;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ManagerMapper {


    @Select("SELECT * FROM seeker WHERE sid=#{sid}")
    Seeker findBysid(int sid);

    @Delete("Delete from seeker where sid=#{sid}")
    void deleteSeeker(int sid);

    @Select("Select * from seeker")
    List<Seeker> showSeeker();

    @Select("Select * from manager where mname=#{mname}")
    Manager findBymname(String mname);

    @Select("Select * from manager where mname=#{mname} AND mpassword=#{mpassword}")
    Manager login(String mname, String mpassword);

    @Select("Select * from position")
    List<Position> showPosition();

    @Select("Select * from position where pid=#{pid}")
    Position findBypid(int pid);

    @Delete("Delete from position where pid=#{pid}")
    void deletePosition(int pid);

    @Delete("Delete from recruit where pid=#{pid}")
    void deleteRecruit(int pid);

    @Select(("Select * from company"))
    List<Company> showCompany();

    @Select("Select * from company where cid=#{cid}")
    Company findBycid(int cid);

    @Delete("Delete from company where cid=#{cid}")
    void deleteCompany(int cid);

    @Delete("Delete from recruit where sid=#{sid}")
    void deleteRecruitBysid(int sid);

    @Delete("Delete from position where cid=#{cid}")
    void deletePositionBycid(int cid);

    @Delete("DELETE FROM recruit WHERE recruit.pid IN (SELECT position.pid FROM position WHERE position.cid = #{cid})")
    void deleteRecruitBycid(int cid);

    @Select("SELECT * FROM position WHERE cid=#{cid}")
    List<Position> findPositionBycid(int cid);

    @Select("Select * from recruit")
    List<Recruit> showRecruit();

    @Select("SELECT * FROM RECruit WHERE sid=#{sid} AND pid=#{pid}")
    Recruit findRecruitBysidpid(int sid,int pid);

    @Update("Update position SET anumber=anumber-1 WHERE pid=#{pid}")
    void revisePositionAnumber(int pid);

    @Delete("Delete from recruit where pid=#{pid} AND sid=#{sid}")
    void deleteRecruitBysidpid(int sid, int pid);
}
